package orm.dictionary;

/**
 * 权限枚举
 * Created by ashin on 2017/11/15.
 */
public enum Role {
    test(0), user(1), vip(2), ow(3), admin(4), finance(5),
    ow1(6), ow2(7), ow3(8), ow4(9);

    private int nCode;

    Role(int nCode) {
        this.nCode = nCode;
    }

    @Override
    public String toString() {
        return String.valueOf(this.nCode);
    }

    /**
     * 是否是管理员组
     *
     * @return
     */
    public static boolean manageGroup(String userRole) {
        if (userRole.equals(String.valueOf(ow)) || userRole.equals(String.valueOf(ow1)) || userRole.equals(String.valueOf(ow2)) || userRole.equals(String.valueOf(ow3))
                || userRole.equals(String.valueOf(ow4)) || userRole.equals(String.valueOf(admin)) || userRole.equals(String.valueOf(finance))
                )
            return true;
        return false;
    }

    /**
     * 是否是房管组
     *
     * @return
     */
    public static boolean roomManageGroup(String userRole) {
        if (userRole.equals(String.valueOf(ow1)) || userRole.equals(String.valueOf(ow2)) || userRole.equals(String.valueOf(ow3))
                || userRole.equals(String.valueOf(ow4)))
            return false;
        return true;
    }

    /**
     * 除了管理员和房间总管
     *
     * @return
     */
    public static boolean withoutLeader(String userRole) {
        if (userRole.equals(String.valueOf(ow1)) || userRole.equals(String.valueOf(ow2)) || userRole.equals(String.valueOf(ow3))
                || userRole.equals(String.valueOf(ow4)) || userRole.equals(String.valueOf(vip)))
            return true;
        return false;
    }
}
